package com.doudou.collection.controller;



import com.doudou.collection.pojo.vo.CommentBlogVO;
import com.doudou.collection.pojo.dto.CommentsDTO;
import com.doudou.collection.pojo.entity.Comments;
import com.doudou.collection.response.ResultVO;
import com.doudou.collection.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Api(tags = "06.评论管理模块")
@Slf4j
@RestController
@RequestMapping("/v1/comment")
public class CommentsController {

    @Autowired
    private CommentService commentService;

    @PostMapping("insert")
    @ApiOperation(value = "文章中发布评论功能")
    public ResultVO insertComment(CommentsDTO commentsDTO){
        log.debug("正在处理发布评论请求,commentsDTO为{}",commentsDTO);
        return commentService.insertComment(commentsDTO);

    }

    @DeleteMapping ("/{id}/delete")
    @ApiOperation(value = "文章中删除评论功能")
    public ResultVO delete(@PathVariable Long id){
        log.debug("正在处理根据id删除评论请求,id为{}",id);
        return commentService.delete(id);
    }

    @GetMapping ("/{id}/selectAll")
    @ApiOperation(value = "文章中评论展示")
    public ResultVO list(@PathVariable Long id){
        log.debug("正在处理根据文章id查询评论列表功能,文章id为 {}", id);
        return commentService.list(id);
    }

    @GetMapping("/{id}/selectPersonalAll")
    @ApiOperation(value = "个人所有评论展示")
    public ResultVO listing(@PathVariable Long id){
        log.debug("正在处理根据用户id查询评论列表功能,用户id为 {}", id);
        return commentService.listing(id);
    }

}
